package com.example.crad.adapter;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.example.crad.R;
import com.example.crad.vo.Message;

import java.util.List;

/**
 * Created by Administrator on 2017/6/17.
 */

public class CardAdapter extends RecyclerView.Adapter<CardAdapter.MyView> {

    private List<Message> list;

    public   CardAdapter(List<Message>list){
        this.list=list;
    }

    @Override
    public MyView onCreateViewHolder(ViewGroup parent, int viewType) {
        View view= LayoutInflater.from(parent.getContext()).inflate(R.layout.item,parent,false);
        return new MyView(view);
    }

    @Override
    public void onBindViewHolder(MyView holder, int position) {
         Message message=list.get(position);
        holder.cardtype.setText(message.getCardtype());
        holder.cardlength.setText(message.getCardlength()+"");
        holder.cardprefixnum.setText(message.getCardprefixnum());
        holder.cardname.setText(message.getCardname());
        holder.bankname.setText(message.getBankname());
        holder.banknum.setText(message.getBanknum());
    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    class MyView extends RecyclerView.ViewHolder{
        private TextView cardtype;
        private TextView cardlength;
        private TextView cardprefixnum;
        private TextView cardname;
        private TextView bankname;
        private TextView banknum;
       public MyView(View itemView) {
           super(itemView);
           cardtype= (TextView) itemView.findViewById(R.id.cardtype);
           cardlength= (TextView) itemView.findViewById(R.id.cradlength);
           cardprefixnum= (TextView) itemView.findViewById(R.id.cardprefixnum);
           cardname= (TextView) itemView.findViewById(R.id.cardname);
           bankname= (TextView) itemView.findViewById(R.id.bankname);
           banknum= (TextView) itemView.findViewById(R.id.banknum);
       }

   }
}
